package com.iot08.api.service;

import com.iot08.common.entity.app.FirstRechargeRenewRemindSetting;
import com.iot08.common.service.base.BaseAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

/**
 * @author cwj
 * @description
 * @date 2025/4/22 14:06
 **/
@Slf4j
@Service
public class FirstRechargeRenewRemindSettingService extends BaseAdminService<FirstRechargeRenewRemindSetting> {

    /**
     * @description 查询指定类型首充或续费提醒配置
     * @author cwj
     * @param [type]
     * @return com.iot08.common.entity.app.FirstRechargeRenewRemindSetting
     * @date @time 2025/4/23 11:43
     **/
    public FirstRechargeRenewRemindSetting queryByType(Integer type) {
        Query query = new Query(Criteria.where("type").is(type));
        query.with(Sort.by(Sort.Order.desc("createTime"))).limit(1);
        return this.findOne(query);
    }
}
